package leetcode_day._2021._202108._2131;

import java.util.Arrays;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/8/23 20:04
 * 获取生成数组中的最大值
 * 算法：模拟
 */
public class _23_1646 {
    public static void main(String[] args) {
        System.out.println(new _23_1646().getMaximumGenerated(7));
    }

    public int getMaximumGenerated(int n) {
        if (n == 0) return 0;
        int[] nums = new int[n + 1];
        nums[0] = 0;
        nums[1] = 1;
        for (int i = 0; i < n; i++) {
            if (2 * i <= n) nums[2 * i] = nums[i];
            if (2 * i + 1 <= n) nums[2 * i + 1] = nums[i] + nums[i + 1];
        }
        System.out.println(Arrays.toString(nums));
        int ans = 0;
        for (int i = 1; i <= n; i++) ans = Math.max(ans, nums[i]);
        return ans;
    }

}
